package com.tianzhu.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonIgnore;


/**
 * The persistent class for the PRODUCT database table.
 * 
 */
@Entity
@Table(name="PRODUCT")
@NamedQuery(name="Product.findAll", query="SELECT p FROM Product p")
public class Product implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="PRODUCT_ID_GENERATOR", sequenceName="PRODUCT_S")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PRODUCT_ID_GENERATOR")
	@Column(unique=true, nullable=false, precision=38)
	private Long id;

	@NotEmpty(message = "The product name must not be empty")
	@Column(name="PRODUCT_NAME", nullable=false)
	private String productName;
	
	@Column(name="PRODUCTCATEGORY")
	private String productcategory;

	@Column(name="PRODUCTCONDITION",length=50)
	private String productcondition;
	
	@Column(name="PRODUCTDESCRIPTION")
	private String productdescription;

	@Column(name="PRODUCTMANUFACTURER",length=200)
	private String productmanufacturer;
	
	@Min(value = 0, message = "The product price must not be less then zero")
	@Column(name="PRODUCTPRICE",precision=126)
	private double productprice;

	@Column(name="PRODUCTSTATUS",length=50)
	private String productstatus;
	
	@Min(value = 0, message = "The product unit must not be less then zero")
	@Column(name="UNITINSTOCK",precision=20)
	private Long unitinstock;
	
	
	@OneToMany(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JsonIgnore
	private List<Cartitem> cartItemList;

	public Product() {
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getProductName() {
		return this.productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getProductcategory() {
		return this.productcategory;
	}

	public void setProductcategory(String productcategory) {
		this.productcategory = productcategory;
	}

	public String getProductcondition() {
		return this.productcondition;
	}

	public void setProductcondition(String productcondition) {
		this.productcondition = productcondition;
	}

	public String getProductdescription() {
		return this.productdescription;
	}

	public void setProductdescription(String productdescription) {
		this.productdescription = productdescription;
	}

	public String getProductmanufacturer() {
		return this.productmanufacturer;
	}

	public void setProductmanufacturer(String productmanufacturer) {
		this.productmanufacturer = productmanufacturer;
	}

	public double getProductprice() {
		return this.productprice;
	}

	public void setProductprice(double productprice) {
		this.productprice = productprice;
	}

	public String getProductstatus() {
		return this.productstatus;
	}

	public void setProductstatus(String productstatus) {
		this.productstatus = productstatus;
	}

	public Long getUnitinstock() {
		return this.unitinstock;
	}

	public void setUnitinstock(Long unitinstock) {
		this.unitinstock = unitinstock;
	}
	
	public List<Cartitem> getCartItemList() {
        return cartItemList;
    }

    public void setCartItemList(List<Cartitem> cartItemList) {
        this.cartItemList = cartItemList;
    }

}